﻿using Caliburn.Micro;
using myapp.Databases.DAO;
using myapp.Events;
using myapp.Instances;
using myapp.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace myapp.ViewModels
{
    /// <summary>
    /// Detail of Possition Group
    /// </summary>
    public class PossitionGroupDetailViewModel : Screen
    {
        #region Attribute
        private IObservableCollection<PossitionModel> _items;
        #endregion

        #region Properties
        /// <summary>
        /// List Possition of Group
        /// </summary>
        public IObservableCollection<PossitionModel> Items
        {
            get
            {
                return _items;
            }
            set
            {
                if (!value.Equals(null))
                {
                    _items = value;
                    NotifyOfPropertyChange(() => Items);
                }
            }
        }
        #endregion

        #region Constructure
        public PossitionGroupDetailViewModel(List<PossitionModel> lstPossition)
        {
            _items = new BindableCollection<PossitionModel>();
            _items.AddRange(lstPossition);
        }
        #endregion

        #region Method
        public void ClickPossiton(PossitionModel position)
        {
            SelectPossitionEvent selectEvent = new SelectPossitionEvent() { SelectedPossition = position };
            MainInstance.Instance.EventAggregator.Publish(selectEvent);
        }
        #endregion
    }
}
